package com.scuec.groupfive;

import lombok.Data;

@Data
public class ResponseResult<T> {
    private int code;
    private String message;
    private T data;

    private ResponseResult(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static <T> ResponseResult<T> ok(T data) {
        return new ResponseResult<>(200, "success", data);
    }

    public static <T> ResponseResult<T> error(int code, String message) {
        return new ResponseResult<>(code, message, null);
    }

    // 新增方法：创建带自定义消息的成功响应
    public static <T> ResponseResult<T> ok(String message, T data) {
        return new ResponseResult<>(200, message, data);
    }

    // 新增方法：创建带状态码和消息的响应
    public static <T> ResponseResult<T> of(int code, String message, T data) {
        return new ResponseResult<>(code, message, data);
    }
}